<?php
	$css_list[0]['url'] = './tpl/css/article.css';
?>
<!--{template inc/header_n}-->

<div class="main_warp">
    <div class="inventory">
        <!--{template inc/list/list_menu}-->

        <div class="i_righter">
			<form id="myform" action="/list.php?action=plan" method="post" enctype="multipart/form-data" onsubmit="return checkform();">
            <div class="cart" style="width:100%;">
                <table class="i_tb">
                    <tr>
                        <td width="70">订单名称</td>
                        <td width="250">{$orderinfo['ordername']}</td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>订单号</td>
                        <td>{$orderinfo['orderid']}</td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>进度执行表</td>
                        <td><a href="/list.php?action=plan&op=showitem&itemid={$itemid}">查看</a></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>退款原因</td>
                        <td><select name="reason">
                            <option value="0"{if $unpayinfo['reason']==0} selected{/if}>未发货</option>
                            <option value="1"{if $unpayinfo['reason']==1} selected{/if}>质量问题</option>
                        </select></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td >退款金额</td>
                        <td><input id="money" type="text" name="money" value="{if $unpayinfo}{$unpayinfo['money']}{else}{$max_money}{/if}" /></td>
                        <td>最多退{$max_money}元</td>
                    </tr>
                    <tr>
                        <td>退款说明</td>
                        <td>
                            <textarea name="intro" style="width:200px;height: 80px;">{$unpayinfo['intro']}</textarea>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>上传凭证</td>
                        <td>
                            {if $num < 3}
                            <div id="picwrap">
                            <input type="file" name="pic[]" onchange="addpic()">
                            </div>
                            {/if}
                            <ul>
                                {if !empty($unpayinfo['pic1'])}
                                <li><img src="{$unpayinfo['pic1']}" width="150" /><a href="/list.php?action=plan&op=delunpaypic&key=pic1&id={$unpayinfo['id']}">删除</a></li>
                                {/if}
                                {if !empty($unpayinfo['pic2'])}
                                <li><img src="{$unpayinfo['pic2']}" width="150" /><a href="/list.php?action=plan&op=delunpaypic&key=pic2&id={$unpayinfo['id']}">删除</a></li>
                                {/if}
                                {if !empty($unpayinfo['pic3'])}
                                <li><img src="{$unpayinfo['pic3']}" width="150" /><a href="/list.php?action=plan&op=delunpaypic&key=pic3&id={$unpayinfo['id']}">删除</a></li>
                                {/if}
                            </ul>
                        </td>
                        <td>最多上传3张</td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <p><input type="submit" name="dounpay" value="提交退款申请"></p>
                        </td>
                        <td></td>
                    </tr>
                </table>
            </div>
            <input type="hidden" name="id" value="{$itemid}">
            <input type="hidden" name="flag" value="1">
			</form>
        </div>
        <br class="g_clear" />
</div>



<!--{template inc/footer}-->
<script type="text/javascript">
var num = <?php echo $num+1?>;
function addpic() {
    if(num >= 3) return;
    $('#picwrap').append('<p><input type="file" name="pic[]" onchange="addpic()"></p>');
    num++;
}

function checkform() {
    var money = $('#money').val();
    if(!/^\d+$/.test(money)) {
        alert('请输入正确的退款金额！')
        return false;
    }

    if(money > {$max_money}) {
        alert('不能超过最大退款金额哦！')
        return false;
    }

    return true;
}
</script>